﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using ValidationFramework.Fluent.Facts.TestModel;
using ValidationFramework.Reflection;
using System.Linq;

namespace ValidationFramework.Fluent.Facts
{
	public class ValidationFacts
	{
		public class ClearRulesFacts
		{
			[Fact]
			public void Should_Clear_Existing_Rules()
			{
				// arrange
				Assert.True(TypeCache.GetType<Product>().GetRuleCount() == 0, "The type helping with test should have no validation rules");
				var desc = TypeCache.GetOrCreatePropertyDescriptor<Product>(x => x.Name);
				desc.Rules.Add(new RequiredStringRule());
				desc.Rules.Add(new RegexRule("a"));
				Assert.True(TypeCache.GetType<Product>().GetRuleCount() == 2, "Rules should have been added by hand");

				// act
				ValidationConfig.ClearRulesFor<Product>();

				// assert
				Assert.True(TypeCache.GetType<Product>().GetRuleCount() == 0, "Should have cleared the rules added by hand");
			}
		}

		public class EnsureFacts
		{
			[Fact]
			public void Should_Return_Correct_Property_Descriptor()
			{
				

			}
		}

	}
}
